</div> <!-- End Main Content -->
</body>
<script type="text/javascript">

	activeMobileNav = false;
	scrollValue = 0;

	$(window).load(function() {

		$('#mobileNavButton').click(mobileNav);

		//==============================================================
		$('.form-hidden').on('click', function(e) {
			e.stopPropagation();
		});

		$('.login-form input[type="submit"]').on('click', function(e) {
			e.stopPropagation();

			username = $('.login-form [name="username"]').val();
			// alert(username);
			password = $('.login-form [name="password"]').val();
			if(username == '' || password == '') {
				$('.login-form .error').html('Vui lòng điền đầy đủ');
			}
			else {
				$.ajax({
					type: "POST",
					url: '/openlibraryonline/user/get_login/',
					data: ({
						user: username,
						pass: password
					}),
					success: function(data) {
						if(data == "dang nhap thanh cong")
							location.reload();
						else {
							$('.login-form .error').html('Username hoặc password không đúng');
							$('.login-form [name="username"]').val('');
							$('.login-form [name="password"]').val('');
						}
					},
					error: function() {
						// alert('Kết nối thất bại');
					}
				});
			}			
			
			return false;

		});

		$('#login-button').on('click', function(e) {
			e.stopPropagation();
			$('.form.login-form').show();
		});
		$('#register-button').on('click', function(e) {
			e.stopPropagation();
			$('.form.register-form').show();
		});
		$('.form-hidden .title i.fa').click(function() {
			$('.form').hide();
		});
		$(document).click(function() {
			$('.form-hidden').hide();
		});

	});

	navOffset = $('#navigation').offset();
	$(window).scroll(function() {
		if($('body').scrollTop() > navOffset.top) {
			$('#navigation').css({
				'width':'100%',
				'position':'fixed',
				'z-index':'9',
				'top':'0',
				'left':'0'
			});
			$('#top-bar').css('margin-bottom','60px');
		}
		else {
			$('#navigation').css('position','static');
			$('#top-bar').css('margin-bottom','0');
		}

		if(!activeMobileNav) scrollValue = $(document).scrollTop();
	});	

	function mobileNav() {
		if(!activeMobileNav) {			
			$('#mobileNav').css('left', 0);

			setTimeout(function() {
				$('#main').css('margin-left','270px');
				$('#top-bar').hide();
				$('.banner').hide();

				activeMobileNav = true;

				$('html, body').css({
				'overflow':'hidden',
				'height':'100%'
			});
			},390);			
		}
		else {
			$('#mobileNav').css('left', '-270px');
			$('#top-bar').show();
			$('.banner').show();
			
			$('#main').css('margin-left','0');
			$('html, body').css({
				'overflow':'auto',
				'height':'auto'
			});
			$(document).scrollTop(scrollValue);
			activeMobileNav = false;
		}
	}

	function loginForm() {
		$('.form.login-form').show();
	}
</script>
</html>